﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using Distrackting.BusinessLayer;

namespace Distrackting.PresentationLayer
{
    public partial class Registo : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void CreateUserWizard1_CreatingUser(object sender, EventArgs e)
        {
            try
            {
                TextBox NomeTextBox = (TextBox) CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Name");
                DropDownList Local = (DropDownList) CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Localidade");
                TextBox DiaTextBox = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Dia");
                TextBox MesTextBox = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Mes");
                TextBox AnoTextBox = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Ano");
                DateTime data = new DateTime(Convert.ToInt32(AnoTextBox.Text), Convert.ToInt32(MesTextBox.Text), Convert.ToInt32(DiaTextBox.Text));
                TextBox TlmTextBox = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Telemovel");
                DropDownList Sexo = (DropDownList) CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Sexo");

                
                HttpContext.Current.Session["CU_nome"] = NomeTextBox.Text;
                HttpContext.Current.Session["CU_cod_loc"] = Local.SelectedValue.ToString();
                HttpContext.Current.Session["CU_data_nasc"] = data.ToString();
                HttpContext.Current.Session["CU_telemovel"] = TlmTextBox.Text;
                HttpContext.Current.Session["CU_sexo"] = Sexo.SelectedValue.ToString();

                
            }
            catch (Exception ex)
            {
                Mensagens.AdicionarErro(ex.Message);
            }   
        }

        protected void CreateUserWizard1_ContinueButtonClick(object sender, EventArgs e)
        {
            Response.Redirect(ResolveUrl("Public.aspx"));
        }
    }
}
